﻿using System;
using System.Linq.Expressions;

namespace SPFluid.Core.Validation
{
    public static class Guard
    {
        public static IGuard<T> That<T>(Expression<Func<T>> argument)
        {
            return ThatInner(new Argument<T>(argument));
        }

        public static IGuard<T> That<T>(T argument)
        {
            return ThatInner(new Argument<T>(argument));
        }

        public static IGuard<T> That<T>(T argument, string argumentName)
        {
            return ThatInner(new Argument<T>(argument, argumentName));
        }

        private static IGuard<T> ThatInner<T>(IArgument<T> argument)
        {
            return new GuardInstance<T>(argument, new ExceptionHandler<T>(argument));
        }
    }
}